#if !defined(__APP_BUFFER_H)
#define __APP_BUFFER_H
#include <pthread.h>
typedef struct
{
    unsigned char *ptr;
    int size;//容量
    int len;//长度
}Sub_buffer;

typedef struct{
    Sub_buffer *sub_buffer[2];//双缓冲区
    int read_index;
    int write_index;
    pthread_mutex_t read_lock;
    pthread_mutex_t write_lock;
}Buffer;

Buffer *app_buffer_init(int size);

void app_buffer_free(Buffer *buffer);

int app_buffer_write(Buffer *buffer,char *data,int len);

int app_buffer_read(Buffer *buffer,char *data,int size);

#endif // __APP_BUFFER_H
